﻿

namespace SvGame.Controller;

public partial class GameHandler
{
    /// <summary>
    /// 玩家进入游戏
    /// </summary>
    /// <param name="pack"></param>
    public int C2GEnterGame(MyPackage pack)
    {
        pack.GetMsg(out C2GEnterGame req);
        var rsp = new G2CEnterGame();

        if (!pack.PackGetPlayer(out var player) || player is null)
        {
            return 0;
        }
        rsp.InfoBase = player.InfoBase();
        rsp.InfoMisc = player.InfoMisc();
        rsp.InfoTalent = player.InfoTalent();
        rsp.InfoStatus = player.InfoStatus();
        rsp.InfoItems = player.InfoItems();
        rsp.InfoEquips = player.InfoEquips();
        rsp.InfoPerform = player.InfoPerform();

        pack.Send(rsp);

        player.Message("登录游戏成功！", EMudColor.HIC);
        player.Room.Message($"{player.Name}连线进入游戏。", player);
        player.RoomInfo();
        player.RoomInit();

        return 0;
    }
    /// <summary>
    /// score
    /// </summary>
    /// <param name="pack"></param>
    public int C2GScore(MyPackage pack)
    {
        pack.GetMsg(out C2GScore req);
        var rsp = new G2CScore();

        if (!pack.PackGetPlayer(out var player) || player is null)
        {
            return 0;
        }
        rsp.InfoTalent = player.InfoTalent();
        rsp.InfoStatus = player.InfoStatus();
        rsp.InfoProps = player.InfoProps();

        return pack.Send(rsp);
    }
}
